from typing import Dict

from fastapi import FastAPI, Body

from api.service.llm_service import add, exist_by_name, list, delete, deletes
from api.vo.form.llm_form import LLM
import api.service.llm_service as llm_service
from api.vo.query.llm_query import LLM_Query

# When `embed` is `True`, the parameter will be expected in a JSON body as a key instead of being the JSON body itself.
async def deletes_llm(factory: str = Body(..., description="模型类型", embed=True)):
    return deletes(factory=factory)


async def list_group_by_model_type():
    return llm_service.list_group_by_model_type()

async def exist_llm(llmQo: LLM_Query):
    return exist_by_name(llmQo.name)


async def list_llms():
    return list()


async def add_llm(llm: LLM):
    return add(llm)


async def test_llm():
    pass


async def delete_llm(id: str = Body(...,description="模型ID", embed=True)):
    return delete(id=id)


async def get_llm():
    pass

def add_llm_routes(app: FastAPI):
    app.get("/llm/list", summary="获取LLM列表", description="获取LLM列表")(list_llms)
    app.get("/llm/list/modelType", summary="根据模型类型分组获取LLM列表", description="根据模型类型分组获取LLM列表")(list_group_by_model_type)
    app.post("/llm/add", summary="添加LLM", description="添加LLM")(add_llm)
    app.post("/llm/delete", summary="删除LLM", description="删除LLM")(delete_llm)
    app.post("/llm/deletes", summary="删除LLM", description="批量删除LLM")(deletes_llm)
    app.get("/llm/get", summary="获取LLM", description="获取LLM")(get_llm)
    app.post("/llm/test", summary="测试LLM", description="测试LLM")(test_llm)